{{ partial "header.html" . }}
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}

	<div class="uk-block uk-block-default">
		<div class="uk-container uk-container-center">
			<div class="uk-grid">
				<div class="uk-width-large-1-10 uk-hidden-medium uk-hidden-small"></div>
				<div id="articleContainer" class="uk-width-large-8-10 uk-width-medium-1-1 uk-width-small-1-1">
					{{ range $paginator.Pages }}
							{{ .Render "list" }}
					{{ end }}

          {{ if not .Site.Params.infiniteScroll }}
          <ul class="uk-pagination">
            {{ if $paginator.HasPrev }}
              <li class="uk-pagination-previous">
                <a href="/page/{{ sub $paginator.PageNumber 1 }}">&lt; Prev</a>
              </li>
            {{ else}}
              <li class="uk-pagination-previous uk-disabled">
                <span>&lt; Prev</span>
              </li>
            {{ end }}

            {{ if $paginator.HasNext }}
              <li class="uk-pagination-next">
                <a href="/page/{{ add $paginator.PageNumber 1 }}">Next &gt;</a>
              </li>
            {{ else}}
              <li class="uk-pagination-next uk-disabled">
                <span>Next &gt;</span>
              </li>
            {{ end }}
          </ul>
          {{ end }}

				</div>
				<div class="uk-width-large-1-10 uk-hidden-medium uk-hidden-small"></div>
			</div>
		</div>
	</div>

{{ partial "footer.html" . }}

<script>
(function () {
  var loadPage = {{ $paginator.PageNumber }};
  var totalPages = {{ $paginator.TotalPages }};
  $('#footer[data-uk-scrollspy]').on('inview.uk.scrollspy', function () {
    loadPage = loadPage + 1;
    if (loadPage > totalPages) { return; }
    $.get('/page/' + loadPage, function (result) {
      $('#articleContainer').append('<hr class="uk-grid-divider">').append($(result).find('article'));
    })
  })
})();
</script>
